﻿using Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IRepository
{
    public interface IInboundOrderRepository
    {
        /// <summary>
        /// 新增入库单（含明细，事务）
        /// </summary>
        Task AddInboundOrderWithDetailsAsync(InboundOrderEntity order, List<InboundOrderDetailEntity2> details);
        Task AddInboundOrderWithDetailsAsync2(InboundOrderEntity order, List<InboundOrderDetailEntity2> details);


        /// <summary>
        /// 开启事务
        /// </summary>
        IDbTransaction BeginTransaction();


        /// <summary>
        /// 多表联查获取入库单列表
        /// </summary>
        Task<List<InboundQueryResult>> GetInboundListAsync(InboundQueryParam param);

        /// <summary>
        /// 获取符合条件的入库单总条数
        /// </summary>
        Task<int> GetInboundTotalAsync(InboundQueryParam param);

        /// <summary>
        /// 按订单号查询进货订单（返回新类名）
        /// </summary>
        /// <param name="purchaseOrderNo"></param>
        /// <returns></returns>
        Task<PurchaseOrderEntity2> GetByOrderNoAsync(string purchaseOrderNo);

        /// <summary>
        /// 更新进货订单状态（参数为新类名）
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task UpdateAsync(InboundOrderEntity entity, IDbTransaction transaction);

        /// <summary>
        /// 按进货ID查询明细（无类名冲突，保持不变）
        /// </summary>
        /// <param name="purchaseId"></param>
        /// <returns></returns>
        Task<List<PurchaseOrderDetailEntity>> GetByPurchaseIdAsync(int purchaseId);
        

        /// <summary>
        /// 根据入库单ID查询主表
        /// </summary>
        /// <param name="warehouseReceiptId"></param>
        /// <returns></returns>
        Task<InboundOrderEntity> GetByIdAsync(int warehouseReceiptId, IDbTransaction transaction);

        /// <summary>
        /// 根据入库单ID查询明细列表
        /// </summary>
        /// <param name="warehouseReceiptId"></param>
        /// <returns></returns>
        Task<List<InboundOrderDetailEntity2>> GetDetailsByReceiptIdAsync(int warehouseReceiptId, IDbTransaction transaction);

    }
}
